package com.xiaoran.RMQ_1.utlis;


import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

//工具类
public class RabbitMqUtils {
    public static final  String QUEUE_NAME="hello";
    public static final  String  IP="192.168.171.132";
    public static Channel getChannel() throws Exception{
        //1.创建连接工厂
        ConnectionFactory connectionFactory=new ConnectionFactory();
        //2 工厂IP连接RabbitMQ的队列
        connectionFactory.setHost(IP);
        //3 设置用户名
        connectionFactory.setUsername("admin");
        //4 设置密码
        connectionFactory.setPassword("123");
        //5 创建连接
        Connection connection=connectionFactory.newConnection();
        //6 创建信道
        com.rabbitmq.client.Channel channel=connection.createChannel();
        return channel;
    }

}
